<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('项目详情')" />
    <th:block th:include="include :: jsonview-css" />
    <th:block th:include="includeProject :: project-css" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12">
                    <th:block th:include="includeProject :: projectInfo" />
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <th:block th:include="includeProject :: projectConstructorInfo" />
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <th:block th:include="includeProject :: approveLogs" />
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <input type="hidden" th:value="${project.projectStatus}" id="projectStatus">
            <button type="button" class="btn btn-sm btn-warning" onclick="closeItem()"><i class="fa fa-reply-all"></i>返 回</button>
            <button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#myModal" id="rejectBtn"><i class="fa fa-remove"></i>驳 回</button>
            <button type="button" class="btn btn-sm btn-primary" onclick="agreeProject()"  id="agreeBtn"><i class="fa fa-check"></i>入 库</button>
        </div>
    </div>
    <div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content animated bounceInRight">
                <div class="" style="padding-left: 4px">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                    </button>
                    <header class="info-header">驳回理由</header>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <textarea rows="5" cols="2000"  class="form-control" name="rejectReason" id="rejectReason" placeholder="请输入驳回理由"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="rejectProject()">驳回</button>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="includeProject :: project-js" />
    <script th:inline="javascript">
        $(document).ready(function(e) {
            // 处理按钮
            var projectStatus = $('#projectStatus').val();

            if (projectStatus == 40 || projectStatus == 30) {
                $('#rejectBtn').remove();
                $('#agreeBtn').remove();
            }
        });

        function rejectProject() {
            var projectId = $('#projectId').val();
            var rejectReason = $('#rejectReason').val();
            $.operate.saveTab(ctx + "manage/approval/reject", {'projectId':projectId,'rejectReason':rejectReason});
        }

        function agreeProject() {
            $.modal.confirm("确定入库项目信息吗？", function() {
                var projectId = $('#projectId').val();
                $.operate.saveTab(ctx + "manage/approval/agree", {'projectId':projectId});
            });
        }
    </script>
</body>
</html>